/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.ungzip;

import cn.ac.iie.di.global.GlobalParas;
import cn.ac.iie.di.tools.FileTools;
import cn.ac.iie.di.tools.UnzipTools;
import java.io.File;
import java.util.List;

/**
 *
 * @author lenovo-pc
 */
public class UngzipTask implements Runnable {

    static org.apache.log4j.Logger logger = null;
    private final String filename;

    static {
        logger = org.apache.log4j.Logger.getLogger(UngzipTask.class.getName());
    }

    public UngzipTask(String filename) {
        this.filename = filename;
    }

    @Override
    public void run() {
        UnzipTools uz = new UnzipTools();
        FileTools ft = new FileTools();
        try {

            //解压文件
            //判断有.sig再解压
            Boolean flag = uz.uncompressFileZIP(GlobalParas.ORI_NEWS, filename, GlobalParas.TMP_NEWS);
            if (!flag) {
                logger.debug("+++++++++" + filename + " unzip error");
                return;
            }
            //移动文件
            File fileok = new File(filename + ".ok");
            if (!fileok.exists()) {
                ft.moveGzFileToNewPath(filename, GlobalParas.DES_NEWS);
            }
        } catch (Exception e) {
            logger.error("=============ungzipTask is error:" + e, e);
        }

    }

    public static void main(String[] args) {
//        GlobalParas.ORI_NEWS = 
        UngzipTask uzt = new UngzipTask("D:\\123\\111\\1030036_querygroupfile_3_WXB_1334403000000000040_final.zip");
        Thread thread = new Thread(uzt);
        thread.start();
    }

}
